
capture log close
clear *
log using paper-log.log, replace

***************************************************************
* Klasnja, Lupu, Tucker: 
* "When Do Voters Sanction Corrupt Politicians?"
* This do file replicates the results show in the main paper: 
* Figures 1-3
***************************************************************

* for further details, see the readme.txt file in the replication archive
* user-written command -coefplot- needed; type 'ssc install coefplot'
* user-written plot scheme -plotplain- needed; type type 'net install gr0070'

*** Figure 1: Conjoint experiment results
use analysis-data, clear
reg vote i.corrupttreat badeconomy##arias i.copartisan i.copsource2 i.female i.country [pw=weight1500], cl(uniq_id)
coefplot, scheme(plotplain) xline(0, lcolor(black) lpattern(solid) lwidth(vthin)) ///
	omitted baselevels graphregion(color(white)) ///
	drop(_cons 0.arias 0.badeconomy#0.arias 0.badeconomy#1.arias 1.badeconomy#0.arias ///
		1.arias 1.badeconomy#1.arias 1.country 2.country 3.country) ///
		xtitle("Effect on Pr(Voting for candidate)") ///
		headings(1.corrupttreat = "{bf:Corruption}" ///
			0.badeconomy = "{bf:Economy} (incumbent only)" ///
			0.female = "{bf: Gender}" ///
			0.copartisan = "{bf:Partisanship}" ///
			0.copsource2 = "{bf:Information source}") ///
		coeflabels(, labsize(small)) mcolor(black) grid(glcolor(gs2)) ///
		msymbol(O) msize(medium)

		
*** Figure 2: Contextual and individual factors mitigating corruption voting
use analysis-data, clear
mat ests = J(11,3,.)
mat diffs = J(4,1,.)
* corruption mitigators: prevalence and side benefits
reg vote i.corrupttreat badeconomy##arias i.copartisan i.copsource2 i.female i.country [pw=weight1500], cl(uniq_id)
margins, dydx(corrupttreat) post
mat tab = r(table)
forval i = 2/4 {
	mat ests[`i',1] = tab[1,`i']
	mat ests[`i',2] = tab[5,`i']
	mat ests[`i',3] = tab[6,`i']
	}
lincom 3.corrupttreat-2.corrupttreat
mat diffs[1,1] = r(estimate)
lincom 4.corrupttreat-2.corrupttreat
mat diffs[2,1] = r(estimate)
* co-partisan bias
reg vote i.corrupttreat##i.copartisan badeconomy##arias i.copsource2 i.female i.country [pw=weight1500], cl(uniq_id)
margins, dydx(2.corrupttreat) at(copartisan = (0 1)) post
mat tab = r(table)
forval i = 3/4 {
	local j = `i'+3
	mat ests[`j',1] = tab[1,`i']
	mat ests[`j',2] = tab[5,`i']
	mat ests[`j',3] = tab[6,`i']
	}
lincom _b[2.corrupttreat:2._at]-_b[2.corrupttreat:1._at]
mat diffs[3,1] = r(estimate)
* justifiability of bribes
reg vote i.corrupttreat##i.bribejust badeconomy##arias i.copartisan i.copsource2 i.female i.country [pw=weight1500], cl(uniq_id)
margins, dydx(2.corrupttreat) at(bribejust = (0 1)) post
mat tab = r(table)
forval i = 3/4 {
	local j = `i'+6
	mat ests[`j',1] = tab[1,`i']
	mat ests[`j',2] = tab[5,`i']
	mat ests[`j',3] = tab[6,`i']
	}
lincom _b[2.corrupttreat:2._at]-_b[2.corrupttreat:1._at]
mat diffs[4,1] = r(estimate)
* creating the graph
clear
svmat ests
gen n = .
for any 1.1 1.5 2 2.5 3.6 4 4.5 5.6 6 6.5 6.7 \ any 1 2 3 4 5 6 7 8 9 10 11: replace n = X in Y
svmat diffs
gen n2 = .
for any 1.75 2 4.25 6.25 \ any 1 2 3 4: replace n2 = X in Y
tostring diffs1, gen(diffs_) force format(%9.3f)
gen stars = "" in 1
replace stars = "***" in 2
replace stars = "**" in 3
replace stars = "*" in 4
egen diffs = concat(diffs_ stars)
gen t = "Diff.: " in 1/4
egen lab = concat(t diffs)
forval i = 1/4 {
	loc l`i' = lab in `i'
	di "`l`i''"
	}
twoway (rcap ests2 ests3 n, msize(0) lcol(black) horizontal) ///
		(scatter n ests1, mcol(black) msize(medium) msymbol(O)), ///
		legend(off) scheme(plotplain) ///
		ylabel(1.1 "{bf: Corruption}" 1.5 "Bribes" 2 "Bribes common" ///
				2.5 "Bribes but jobs" 3.6 "{bf: Co-partisan bias}" ///
				4 "Bribes & out-partisan candidate" 4.5 "Bribes & co-partisan candidate" ///
				5.6 "{bf: Bribe tolerance}" 6 "Bribes & low tolerance" ///
				6.5 "Bribes & high tolerance", labgap(6pt) noticks nogrid angle(0) labsize(small)) ytitle("") ///
		xscale(range(-0.6(.1)0)) xlabel(#4, glcolor(gs2)) xtitle("Effect on Pr(Voting for candidate)") ///
		yscale(reverse )  ytick(1.5 2 2.5 4 4.5 6 6.5, grid glcolor(gs2)) ///
		xline(0, lcolor(black) lpattern(dash) lwidth(vthin)) ///
		text(1.71 -.41 "`=ustrunescape("\u23A7")'" "`=ustrunescape("\u23A8")'" "`=ustrunescape("\u23A9")'" , size(small) color(black)) ///
		text(1.75 -.47 "`l1'", size(small)) ///
		text(1.9 -.2 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(vlarge) color(black)) ///
		text(1.95 -.13 "`l2'", size(small)) ///
		text(4.23 -.3 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(small) color(black)) ///
		text(4.25 -.24 "`l3'", size(small)) ///
		text(6.23 -.18 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(small) color(black)) ///
		text(6.25 -.12 "`l4'", size(small)) 


*** Figure 3: What conditions amplify the mitigating effect of side benefits?
use analysis-data, clear
mat ests = J(13,3,.)
mat diffs = J(6,1,.)
* respondents' education
reg vote i.corrupttreat##i.loed2 badeconomy##arias i.copartisan i.copsource2 i.female i.country [pw=weight1500], cl(uniq_id)
local j = 2
foreach i in 2 3 {
	lincom `j'.corrupttreat
	mat ests[`i',1] = r(estimate)
	mat ests[`i',2] = r(lb)
	mat ests[`i',3] = r(ub)
	local j = `j' + 2
	}
lincom 4.corrupttreat-2.corrupttreat
mat diffs[1,1] = r(estimate)
lincom 2.corrupttreat+2.corrupttreat#1.loed2
mat ests[5,1] = r(estimate)
mat ests[5,2] = r(lb)
mat ests[5,3] = r(ub)
lincom 4.corrupttreat+4.corrupttreat#1.loed2
mat ests[6,1] = r(estimate)
mat ests[6,2] = r(lb)
mat ests[6,3] = r(ub)
lincom 4.corrupttreat+4.corrupttreat#1.loed2-(2.corrupttreat+2.corrupttreat#1.loed2)
mat diffs[2,1] = r(estimate)
lincom 4.corrupttreat+4.corrupttreat#1.loed2-(2.corrupttreat+2.corrupttreat#1.loed2)-(4.corrupttreat-2.corrupttreat)
mat diffs[3,1] = r(estimate)
* respondents' wealth
reg vote i.corrupttreat##i.lowealth badeconomy##arias i.copartisan i.copsource2 i.female i.country [pw=weight1500], cl(uniq_id)
local j = 2
foreach i in 8 9 {
	lincom `j'.corrupttreat
	mat ests[`i',1] = r(estimate)
	mat ests[`i',2] = r(lb)
	mat ests[`i',3] = r(ub)
	local j = `j' + 2
	}
lincom 4.corrupttreat-2.corrupttreat
mat diffs[4,1] = r(estimate)
lincom 2.corrupttreat+2.corrupttreat#1.lowealth
mat ests[11,1] = r(estimate)
mat ests[11,2] = r(lb)
mat ests[11,3] = r(ub)
lincom 4.corrupttreat+4.corrupttreat#1.lowealth
mat ests[12,1] = r(estimate)
mat ests[12,2] = r(lb)
mat ests[12,3] = r(ub)
lincom 4.corrupttreat+4.corrupttreat#1.lowealth-(2.corrupttreat+2.corrupttreat#1.lowealth)
mat diffs[5,1] = r(estimate)
lincom 4.corrupttreat+4.corrupttreat#1.lowealth-(2.corrupttreat+2.corrupttreat#1.lowealth)-(4.corrupttreat-2.corrupttreat)
mat diffs[6,1] = r(estimate)
* creating the graph
clear
svmat ests
gen n = .
for any 1.1 1.5 2 3.1 3.5 4 5.6 6 6.5 7.6 8 8.5 8.7 \ any 1 2 3 4 5 6 7 8 9 10 11 12 13: replace n = X in Y
svmat diffs
gen n2 = .
for any 1.75 3.75 2.75 6.25 8.25 7.25 \ any 1 2 3 4 5 6: replace n2 = X in Y
tostring diffs1, gen(diffs_) force format(%9.3f)
gen stars = "" in 1
replace stars = "***" in 2
replace stars = "**" in 3
replace stars = "***" in 4
replace stars = "***" in 5
replace stars = "*" in 6
egen diffs = concat(diffs_ stars)
gen t = "Diff.: " in 1/6
egen lab = concat(t diffs)
forval i = 1/6 {
	loc l`i' = lab in `i'
	di "`l`i''"
	}
twoway (rcap ests2 ests3 n, msize(0) lcol(black) horizontal) ///
		(scatter n ests1, mcol(black) msize(medium) msymbol(O)), ///
		legend(off) scheme(plotplain) ///
		ylabel(1.1 "{bf: High education}" 1.5 "Bribes" 2 "Bribes but jobs" ///
				3.1 "{bf: Low education}" 3.5 "Bribes" 4 "Bribes but jobs" ///
				5.6 "{bf: High wealth}" 6 "Bribes" 6.5 "Bribes but jobs" ///
				7.6 "{bf: Low wealth}" 8 "Bribes" 8.5 "Bribes but jobs", ///
				labgap(5pt) noticks nogrid angle(0) labsize(small)) ytitle("") ///
		xscale(range(-0.6(.1).1)) xlabel(#6, glcolor(gs2)) xtitle("Effect on Pr(Voting for candidate)") ///
		yscale(reverse )  ytick(1.5 2 3.5 4 6 6.5 8 8.5, grid glcolor(gs2)) ///
		xline(0, lcolor(black) lpattern(dash) lwidth(vthin)) ///
		text(1.73 -.33 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(small) color(black)) ///
		text(1.75 -.27 "`l1'", size(small)) ///
		text(3.73 -.17 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(small) color(black)) ///
		text(3.75 -.10 "`l2'", size(small)) ///
		text(2.63 .025 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(vhuge) color(black)) ///
		text(2.79 .115 "`l3'", size(medium)) ///
		text(6.23 -.29 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(small) color(black)) ///
		text(6.25 -.22 "`l4'", size(small)) ///
		text(8.23 -.15 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(small) color(black)) ///
		text(8.25 -.08 "`l5'", size(small)) ///
		text(7.13 .025 "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'" "`=ustrunescape("\u23AD")'" , size(vhuge) color(black)) ///
		text(7.29 .115 "`l6'", size(medium)) yline(5, lpattern(solid) lcolor(gray) lwidth(thin))


graph drop _all

log close
** end of do-file